﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.mainmenu {
    import reprise.ui.*;
    import flash.events.*;
    import reprise.events.*;
    import reprise.controls.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.utils.*;

    public class ShopMenu extends SimpleButton {

        private const FACADE_VISIBLE:String = "facadeVisible";
        private const FACADE_HIDDEN:String = "facadeHidden";

        private var _tabButtonsRadioGroup:RadioButtonGroup;
        private var _selectedCategory:String;
        private var _tabButtonsDisplay:UIComponent;
        private var _facadeButtonsGroup:RadioButtonGroup;
        private var _facadeState:String;
        private var _facadeInsideButton:RadioButton;
        private var _facadeOutsideButton:RadioButton;
        private var _numberOfFreeSlotsLabel:Label;

        public static const TAB_OBJECTS:String = "objects";
        public static const TAB_DESIGNS:String = "designs";
        public static const TAB_ROOMS:String = "rooms";
        public static const TAB_WALLS:String = "walls";
        public static const TAB_FLOORS:String = "floors";

        public function isOpen():Boolean{
            return (hasCSSClass("show"));
        }
        override public function show(... _args):void{
            super.show();
            addEventListener(TransitionEvent.ALL_TRANSITIONS_COMPLETE, this.show_allTransitionsComplete);
            mouseEnabled = (mouseChildren = false);
            addCSSClass("show");
            dispatchEvent(new MainMenuEvent(MainMenuEvent.SHOP_MENU_OPEN));
        }
        override public function hide(... _args):void{
            addEventListener(TransitionEvent.ALL_TRANSITIONS_COMPLETE, this.hide_all_transitionsComplete);
            mouseEnabled = (mouseChildren = false);
            removeCSSClass("show");
        }
        private function show_allTransitionsComplete(_arg1:TransitionEvent):void{
            removeEventListener(TransitionEvent.ALL_TRANSITIONS_COMPLETE, this.show_allTransitionsComplete);
            mouseEnabled = true;
            mouseChildren = true;
        }
        private function hide_all_transitionsComplete(_arg1:TransitionEvent):void{
            removeEventListener(TransitionEvent.ALL_TRANSITIONS_COMPLETE, this.hide_all_transitionsComplete);
            mouseEnabled = false;
            mouseChildren = false;
            dispatchEvent(new MainMenuEvent(MainMenuEvent.SHOP_MENU_CLOSED));
            super.hide();
        }
        public function get tabButtonsRadioGroup():RadioButtonGroup{
            return (this._tabButtonsRadioGroup);
        }
        public function setLabels(_arg1:String, _arg2:String, _arg3:String, _arg4:String, _arg5:String):void{
            var _local6:Array = this._tabButtonsRadioGroup.radioButtons();
            RadioButton(_local6[0]).setLabel(_arg1);
            RadioButton(_local6[1]).setLabel(_arg2);
            RadioButton(_local6[2]).setLabel(_arg4);
            RadioButton(_local6[3]).setLabel(_arg5);
            RadioButton(_local6[4]).setLabel(_arg3);
        }
        public function setNumberOfFreeSlots(_arg1:int):void{
            this._numberOfFreeSlotsLabel.setVisibility((_arg1 > 0));
            this._numberOfFreeSlotsLabel.setLabel(String(_arg1));
        }
        public function setNavigationActive(_arg1:Boolean):void{
            var _local5:RadioButton;
            var _local2:Array = getElementsByClassName("customizeTabButton");
            var _local3:Array = getElementsByClassName("customizeFacadeButton");
            var _local4:SimpleButton = getElementsByClassName("customizedCloseButton")[0];
            for each (_local5 in _local2) {
                _local5.enabled = _arg1;
            };
            for each (_local5 in _local3) {
                _local5.enabled = _arg1;
            };
            _local4.enabled = _arg1;
        }
        public function setHoverActive(_arg1:Boolean):void{
            if (_arg1){
                addCSSClass("activeHover");
            } else {
                removeCSSClass("activeHover");
            };
        }
        public function selectCategory(_arg1:String):void{
            var _local2:RadioButton;
            _local2 = getElementsByClassName("customizeTabButton")[0];
            this._tabButtonsRadioGroup.selectRadioButtonWithData(_arg1);
        }
        public function createFacadeButtons(_arg1:String, _arg2:String, _arg3:Boolean):void{
            this._facadeInsideButton = RadioButton(addComponent("customizeFacadeButton customizeFacadeInsideButton", null, RadioButton));
            this._facadeInsideButton.setData("inside");
            this._facadeInsideButton.setLabel(_arg1);
            this._facadeInsideButton.setGroupName("facadeButtons");
            this._facadeOutsideButton = RadioButton(addComponent("customizeFacadeButton customizeFacadeOutsideButton", null, RadioButton));
            this._facadeOutsideButton.setData("outside");
            this._facadeOutsideButton.setLabel(_arg2);
            this._facadeOutsideButton.setGroupName("facadeButtons");
            this._facadeButtonsGroup = this._facadeOutsideButton.group();
            this._facadeButtonsGroup.setRadioButtonSelected(this._facadeOutsideButton, _arg3);
            this._facadeButtonsGroup.setRadioButtonSelected(this._facadeInsideButton, !(_arg3));
            this._facadeButtonsGroup.addEventListener(Event.CHANGE, this.facadeButtonsGroup_change);
        }
        public function createHoverLayer():void{
            addComponent("hoverLayer");
        }
        public function fitMenuToFacadeState(_arg1:Boolean):void{
            this._facadeButtonsGroup.removeEventListener(Event.CHANGE, this.facadeButtonsGroup_change);
            this._facadeOutsideButton.selected = _arg1;
            this._facadeInsideButton.selected = !(_arg1);
            this._facadeButtonsGroup.addEventListener(Event.CHANGE, this.facadeButtonsGroup_change);
            this._facadeState = (_arg1) ? this.FACADE_VISIBLE : this.FACADE_HIDDEN;
            if (_arg1){
                this._tabButtonsDisplay.cssID = this._facadeState;
            } else {
                this._tabButtonsDisplay.cssID = this._facadeState;
            };
            this._tabButtonsDisplay.addEventListener(DisplayEvent.VALIDATION_COMPLETE, this.tabButtonsDisplay_validationComplete);
        }
        private function tabButtonsDisplay_validationComplete(_arg1:DisplayEvent):void{
            this._tabButtonsDisplay.removeEventListener(DisplayEvent.VALIDATION_COMPLETE, this.tabButtonsDisplay_validationComplete);
            this.checkIfSelectedCategoryIsValid();
        }
        private function checkIfSelectedCategoryIsValid():void{
            var _local1:RadioButton;
            for each (_local1 in this._tabButtonsRadioGroup.radioButtons()) {
                if ((((this._selectedCategory == _local1.data())) && ((_local1.style.display == "none")))){
                    this._tabButtonsRadioGroup.selectRadioButtonWithData(TAB_OBJECTS);
                };
            };
        }
        private function facadeButtonsGroup_change(_arg1:Event):void{
            var _local2:RadioButtonGroup = RadioButtonGroup(_arg1.target);
            dispatchEvent(new ViewCompEvent(ViewCompEvent.CLICK, _local2.selectedData()));
        }
        override protected function initialize():void{
            super.initialize();
            cssID = "shopMenu";
            addCSSClass("myriadProFont");
        }
        override protected function createChildren():void{
            var _local1:UIComponent = addComponent("background");
            _local1.cacheAsBitmap = true;
            var _local2:SimpleButton = SimpleButton(addComponent("customizedCloseButton", null, SimpleButton));
            _local2.addEventListener(MouseEvent.CLICK, this.customizeCloseButton_click);
            this.createTabDisplay();
            this.createTabNavigation();
        }
        private function createTabDisplay():void{
            ObjectsTabDisplay(addChild(new ObjectsTabDisplay()));
            DesignsTabDisplay(addChild(new DesignsTabDisplay()));
            FloorsTabDisplay(addChild(new FloorsTabDisplay()));
            WallsTabDisplay(addChild(new WallsTabDisplay()));
            RoomsTabDisplay(addChild(new RoomsTabDisplay()));
        }
        private function createTabNavigation():void{
            var _local1:RadioButton;
            this._tabButtonsDisplay = addComponent("tabButtonDisplay");
            _local1 = RadioButton(this._tabButtonsDisplay.addComponent("customizeTabButton buttonObjects", null, RadioButton));
            _local1.setData(TAB_OBJECTS);
            _local1.setGroupName("customizeRadioGroup");
            _local1 = RadioButton(this._tabButtonsDisplay.addComponent("customizeTabButton buttonDesigns", null, RadioButton));
            _local1.setData(TAB_DESIGNS);
            _local1.setGroupName("customizeRadioGroup");
            _local1 = RadioButton(this._tabButtonsDisplay.addComponent("customizeTabButton buttonFloors", null, RadioButton));
            _local1.setData(TAB_FLOORS);
            _local1.setGroupName("customizeRadioGroup");
            _local1 = RadioButton(this._tabButtonsDisplay.addComponent("customizeTabButton buttonWalls", null, RadioButton));
            _local1.setData(TAB_WALLS);
            _local1.setGroupName("customizeRadioGroup");
            _local1 = RadioButton(this._tabButtonsDisplay.addComponent("customizeTabButton buttonRooms", null, RadioButton));
            _local1.setData(TAB_ROOMS);
            _local1.setGroupName("customizeRadioGroup");
            this._numberOfFreeSlotsLabel = RepriseUtils.addLabel(_local1, "numberLabel myriadProFont");
            this._tabButtonsRadioGroup = _local1.group();
            this._tabButtonsRadioGroup.addEventListener(Event.CHANGE, this.radioGroup_change);
            this._tabButtonsRadioGroup.selectRadioButtonWithData(TAB_OBJECTS);
        }
        private function radioGroup_change(_arg1:Event):void{
            ((this._selectedCategory) && (removeCSSClass(this._selectedCategory)));
            var _local2:RadioButton = this._tabButtonsRadioGroup.selectedRadioButton();
            this._selectedCategory = _local2.data();
            addCSSClass(this._selectedCategory);
        }
        private function customizeCloseButton_click(_arg1:MouseEvent):void{
            this.hide();
        }

    }
}//package net.wooga.pets.views.components.mainmenu 
